package br.unifor.mia.graph.setorcensitario;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;

@Entity
public class UserInfo {

	@EmbeddedId
	private UserInfoId userInfoId;
	
	private int crimesInTailSector;
	
	private int crimesInHeadSector;

	/**
	 * Default Constructor, used by Hibernate.
	 */
	public UserInfo() {
		// Default Constructor, used by Hibernate.
	}
	
	public UserInfo(String userName, SectorLink sectorLink, int crimesInTailSector, int crimesInHeadSector) {
		this.userInfoId = new UserInfoId(userName, sectorLink);
		this.crimesInTailSector = crimesInTailSector;
		this.crimesInHeadSector = crimesInHeadSector;
	}

	public UserInfoId getUserInfoId() {
		return userInfoId;
	}

	public int getCrimesInTailSector() {
		return crimesInTailSector;
	}

	public int getCrimesInHeadSector() {
		return crimesInHeadSector;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((userInfoId == null) ? 0 : userInfoId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof UserInfo)) {
			return false;
		}
		UserInfo other = (UserInfo) obj;
		if (userInfoId == null) {
			if (other.userInfoId != null) {
				return false;
			}
		} else if (!userInfoId.equals(other.userInfoId)) {
			return false;
		}
		return true;
	}
}
